// pages/tabBar/enterprise/enterprise.js 企业目录
import { request, upRequest, wxuuid } from "../../../utils/util.js"
const { $Message } = require('../../../dist/base/index');
Page({

  /**
   * 页面的初始数据
   */
  data: {
    fileList: [],    //文件夹列表
    isLoading: true,  //控制是否加载态
    classifyType: "org",  //设定类型
    visible1: false,   //原右下角控制展示
    actions1: [         //原右下角功能渲染
      
      {
        name: '新建文件夹',
        color: "#487ff8"
      },
    ],
    visibleCreate: false  //原新建文件夹是否展示
  },



  /**
   * 生命周期函数--监听页面显示
   * 设置了获取列表和设置location
   */
  onShow: function () {
    
    wx.setStorageSync('location', "org")
    this.getFileList();

  },


  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {
    const that = this
    const param = {
      type: this.data.classifyType
    }
    request("GET", "/api/service/catalog", param).then(res => {
      that.setData({
        fileList: res.data.data
      })
      wx.stopPullDownRefresh()
    })


  },

  /**
   * 获取数据的封装
   */
  getFileList() {
    const that = this
    const param = {
      type: this.data.classifyType
    }
    request("GET", "/api/service/catalog", param).then(res => {
      that.setData({
        ...that.data,
        fileList: res.data.data,
        isLoading: false
      })

    })
  },
  /**
     * 打开上啦菜单
     */
  add() {
    this.setData({
      visible1: true
    });
  },
  /**
   * 关闭上啦菜单
   */
  handleCancel1() {
    this.setData({
      visible1: false
    });
  },
  /**
   * 上啦框里的各个事件
   * @param {}} param0 
   */
  handleClickItem1({ detail }) {
      this.selectComponent("#inputModal").setShow()
  },
  /**
   * 测试用调用展示MSg
   * @param {*} e 
   */
  showMsg: function (e) {
    const mes = e.detail
    $Message({
      content: mes
    });
  }
})